import React, { Component } from 'react'
import { HashRouter, Route, Switch } from 'react-router-dom'
import znCH from 'antd/lib/locale-provider/zh_CN'
import { LocaleProvider  } from 'antd'
import App from './App'
import Login from 'pages/login/login'
import Home from 'pages/home/home'
import NoMatch from 'pages/noMatch/noMatch'
import MainPage from 'pages/home/mainPage/mainPage'

export default class Router extends Component {
  render() {
    return (
      <LocaleProvider locale={znCH}>
        <HashRouter>
          <App>
            <Switch>
              <Route exact path="/" render={props => <Login {...props}/>}></Route>
              <Route exact path="/login" render={props => <Login {...props}/>}></Route>
              <Route path="/home" render={ () => 
                <Home>
                  <Switch>
                    <Route exact path="/home" component={ MainPage }></Route>
                    <Route path="/home/mainPage" component={ MainPage }></Route>
                    <Route component={ NoMatch }></Route>
                  </Switch>
                </Home>
              }></Route>
              <Route component={ NoMatch }></Route>
            </Switch>
          </App>
        </HashRouter>
      </LocaleProvider>
    )
  }
}
